﻿mui.init({
	swipeBack:false, //启用右滑关闭功能
	keyEventBind: {
		backbutton: false  //关闭back按键监听
	}
}); 
mui.plusReady(initSomething);

var userid;
function initSomething(){
	var self = plus.webview.currentWebview();
	$("#title").html(self.title);
	userid = common.utils.getUserId();
	initNotice();
}

//获取数据
function initNotice(){
	var self = plus.webview.currentWebview();
	var type = self.type;
	$("#loading").show();
	mui.ajax(ctx+"mobile/common/getContentList?type="+type,{
		dataType:'json',//服务器返回json格式数据
		type:'post',//HTTP请求类型
		timeout:10000,//超时时间设置为10秒；	              
		success:function(data){
	       	if(data&&data.success){
	       		var html = "";
	       		if(data.data){
	       			var list = data.data;
	       			$.each(list,function(i,d){
	       				if(!d.img){
	       					d.img="../../img/app/defaultImg.png"
	       				}else{
	       					d.img=ctx+d.img;
	       				}
	       				html = html + '<li class="mui-table-view-cell mui-media contentLi" data-id="'+d.id+'">';
							html = html + '<a href="javascript:;">';
								html = html + '<img class="mui-media-object mui-pull-left" src="'+d.img+'">';
								html = html + '<div class="mui-media-body">';
									html = html + d.title;
									html = html + '<p class="mui-ellipsis">'+(d.text_content?d.text_content:'')+'</p>';
								html = html + '</div>';
							html = html + '</a>';
						html = html + '</li>';
	       			});
	       			$("#contentList").html(html);
	       			$("#contentList").show();
	       			$(".contentLi").on("tap",function(){//详情页面
						var content = plus.webview.create("../content/content.html", "../content/content.html", {scrollIndicator:'none'},{type:'6',dataId:$(this).attr("data-id")});
						//	显示新页面
						plus.webview.show(content, "slide-in-right", "350ms", function() {}, false);
					});
	       		}
	      	}else{
	      		alert('服务器异常链接失败!');
	      	}
		},
		error:function(xhr,type,errorThrown){
			alert('服务器异常链接失败!');
		}
	});

}
